package com.wing.cabinet.model.entity;

import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 用户暂存柜产品货道库存
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("cab_storage_inventory_user")
public class StorageInventoryUser extends BaseEntity<StorageInventoryUser> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum BusinessType implements IEnum<Integer> {

        /**
        * 暂存
        */
        temp(1,"暂存"),
        /**
        * 维修
        */
        repair(2,"维修"),
        /**
        * 回收
        */
        recycle(3,"回收"),
        /**
         * 格子柜上货
         */
        exhibit(4,"格子柜上货");

        private int code;
        private String desc;

        BusinessType(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }

        @JsonCreator
        public static BusinessType jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (BusinessType item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 柜子id
     */
    private Long cabId;

    /**
     * 柜子编号
     */
    private String cabCode;

    /**
     * 货道id
     */
    private Long spaceId;

    /**
     * 货道编号
     */
    private String spaceCode;

    /**
     * sku id
     */
    private Long skuId;

    /**
     * sku 编号
     */
    private String skuCode;

    /**
     * 库存数量
     */
    private Integer quantity;

    /**
     * 业务类型
     */
    private BusinessType businessType;

    /**
    * 业务类型描述
    */
    @TableField(exist = false)
    private String businessTypeDesc;

    public String getBusinessTypeDesc() {
        return businessType == null ? null : businessType.getDesc();
    }

    /**
     * 是否已同步：no(0,未同步);yes(1,已同步);
     */
    private Integer isSyns;

    /**
    * 同步时间
    */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime synsTime;


    private Long companyId;

    private String deviceCode;

    private String creatorNickname;

    private String labelCode;

    private Long workOrderId;

    /**
     * 企业编码
     */
    private String enterpriseCode;
    /**
     * 渠道编号
     */
    private String channelCode;

    private Long processId;

    private Long departmentId;

    private Long roleId;

    private String departmentName;

    private String roleName;

    private Integer quantityPack;

    private Integer quantityPackUnit;

    private Long packId;

    private String packName;

    private String unitName;

    private BigDecimal price;

    private BigDecimal total;


}
